//
//  CellOfActivity.m
//  PetAPP
//
//  Created by apple on 16/2/5.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "CellOfActivity.h"
#import "ModelOfActivity.h"
#import <YYWebImage.h>
#import <DKNightVersion.h>

@interface CellOfActivity ()

@property (nonatomic, retain) UIImageView *imageViewOfCover;

@property (nonatomic, retain) UILabel *labelOfTitle;

@property (nonatomic, retain) ModelOfActivity *modelOfSelf;

@end

@implementation CellOfActivity


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor grayColor]);
    }
    return self;
}


- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

    [self.delegate pushNewVCWithModel:self.modelOfSelf];


}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.labelOfTitle.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 30);
    self.labelOfTitle.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    self.imageViewOfCover.frame = CGRectMake(0, 30, self.contentView.frame.size.width, 170);
    
    

}

- (void)passPicAndTitleWithModel:(ModelOfActivity *)model {
    
    self.modelOfSelf = model;
//    self.imageViewOfCover.yy_imageURL = [NSURL URLWithString:model.cover];
    [self.imageViewOfCover yy_setImageWithURL:[NSURL URLWithString:model.cover] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];
    
    self.labelOfTitle.text = [NSString stringWithFormat:@"      #%@#", model.act_title];
    
    
    
}


- (void)createSubViews {

    self.imageViewOfCover = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageViewOfCover];
    [_imageViewOfCover release];
    
    self.labelOfTitle = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfTitle];
    [_labelOfTitle release];
    
    

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
